import Vuex from 'vuex'

let d = window.sessionStorage.getItem("userInfo");

const state = {
    userInfo: {
        username: '',
        password: '',
        token: '',
        isLogin: false
    }
}
if (d) {
    d = JSON.parse(d);
    state.userInfo = d;
}
const mutations = {
    // 注销
    loginOut(state) {
        state.userInfo = {
            username: '',
            password: '',
            token: '',
            isLogin: false
        };
        window.sessionStorage.removeItem("userInfo");
    },
}
const getters = {}
export default new Vuex.Store({
    state,
    mutations,
    getters
});